Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash in FileAccessCompressed and improve error handling #77306

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RedworkDE
Copy link
Member

@RedworkDE RedworkDE commented May 21, 2023

Fixes partially #62585 (on MSVC #74582 is also required or it will just crash in CowData::resize before any of this matters)

Only the change in WRITE_FIT is strictly required to fix the crash.
The error handling improvements are required so that ResourceSaver::save doesn't OK when output file will be corrupted, with them it correctly returns ERR_CANT_CREATE.
Without the FileAccessCompressed::store_buffer implementation, the file writing will instead get stuck spamming errors for each byte in the buffer.

@RedworkDE RedworkDE force-pushed the file-access-compressed-error-handling branch from 49b7ccc to 30fee2e Compare May 22, 2023 18:44
@Calinou
Copy link
Member

Calinou commented Jun 18, 2023

The behavior of this PR rebased against master a83eb16 is the same as in the linked issue on Linux: no crash, but I still see the error message:

ERROR: Condition "p_size < 0" is true. Returning: ERR_INVALID_PARAMETER
   at: resize (./core/templates/cowdata.h:262)

test.res weighs 544,482,622 bytes when I exit the MRP after the error message is printed.

@RedworkDE
Copy link
Member Author

Other than the resize crash on MSVC, the crash caused by this might be ASAN only iirc.

Also the main difference is that with the PR ResourceSaver::save returns ERR_CANT_CREATE instead of OK when it fails. The save failing can't be fixed without redesigning how the compressed files work or adding support for 2GB+ arrays (and even then this PR is still useful as saving can still fail in some cases where it then still shouldn't return OK)

@akien-mga akien-mga modified the milestones: 4.1, 4.2 Jun 22, 2023
@akien-mga akien-mga added cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release and removed cherrypick:4.0 labels Jun 22, 2023
@YuriSizov YuriSizov modified the milestones: 4.2, 4.3 Oct 30, 2023
@YuriSizov YuriSizov added the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Oct 30, 2023
@TokisanGames
Copy link
Contributor

TokisanGames commented Jan 19, 2024

With PR #86730 merged, Godot still crashes in #62585. Applying this PR on top, it replaces the crash with an error popup. However large resource files are still not saved. See #62585 (comment) for details.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good to me.

I'll unlink #62585 as it won't be fully fixed yet, but this seems to be a step in the right direction.

@akien-mga
Copy link
Member

Would be worth rebasing as this was last updated a year ago.

@akien-mga akien-mga modified the milestones: 4.3, 4.4 May 28, 2024
@akien-mga akien-mga added cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release and removed cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release labels May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release crash topic:core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants